Allow trailing self in more contexts#155137
Conversation
|
@rustbot review |
|
Reminder, once the PR becomes ready for a review, use |
Description for lang teamThis PR implements the last part of the lang team guidance from #146972 (comment). Concretely, after this PR
And technically, this PR will not break existing code. |
|
@rustbot review |
|
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@rfcbot reviewed |
|
@rfcbot reviewed |
1 similar comment
|
@rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The Reference says that `self` can only appear as the first segment of
a path. Further, the `use` chapter describes `{self}` brace syntax as
the way to bind the parent entity of a `use` path under its own name.
In rust-lang/rust#155137, we're relaxing these restrictions: `self`
may now also appear as the last segment of a path (preceded by `::`)
as long as the preceding path resolves to a module, enumeration,
or trait. In a `use` path, `use P::self [as name]` is equivalent
to `use P::{self [as name]}`. In non-`use` paths, forms such as
`type Ty = P::self` and `pub(in P::self)` are now accepted.
Let's update the Reference to reflect this.
|
Reference PR: cc @rust-lang/lang-docs @rust-lang/fls |
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Reference PR:
selfin paths reference#2237View all comments
As a follow-up PR to #152996, after this PR:
selfcan appear in pathsuse ...::self [as target];will be equivalent touse ...::{self [as target]};r? petrochenkov